package ai.evadeControllers;

import ai.AbstractPilotController;
import logic.common.player.Player;
import logic.nodes.TeamNode;
import logic.ships.hunter.Hunter;

/**
 * Simply flies the {@link Hunter} away from the {@link Player}'s target and enables boost.
 * 
 * @author Wasserleiche
 */
public abstract class EvadeController extends AbstractPilotController {
	
	private static final long serialVersionUID = 1L;
	
	public EvadeController(Player bot) {
		super(bot);
	}
	
	@Override
	public void delayedUpdate(float time) {
		if(!checkAIEnabled()) return;
		
		super.delayedUpdate(time);
		TeamNode target = bot.getBotTarget();
		if(target == null) return;

		bot.getHunter().getMoveForwardController().stop(false);
		
		evade(time);
	}
	
	protected abstract void evade(float time);
	
	protected void useCounterMeasures() {
		Hunter hunter = bot.getHunter();
		if(hunter.hasAttackingHeatSeeker()) hunter.useCounterMeasures();
	}
}